home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Communication / LibraryOfCongress / Source / MyMenuCell.m < prev    next >
Text File  |  1994-05-23  |  1KB  |  58 lines

  1. #import "MyMenuCell.h"
  2. #import <appkit/appkit.h>
  3.  
  4. @implementation  MyMenuCell
  5.  
  6. fixItem(p) char *p; {
  7.     int nl=1;
  8.     char *l = p;
  9.     squishblank(p);
  10.     while (*p){
  11.         if (*p==':' && nl && p[1])
  12.             p[1]='\t', nl=0;
  13.         else
  14.         if (*p=='\n') nl=1;
  15.         p++;
  16.     }
  17. }
  18.  
  19. - click:sender {
  20.     char buf[80000], *p = buf;
  21.     if (getItem(buf,n)){
  22.         if (strncmp(p,"\n(Record",8)==0) p = index(p,')')+1;
  23.         fixItem(p);
  24.         setText(p);
  25.     }
  26.     return self;
  27. }
  28.  
  29. - setStringValueNoCopy:(char *)s {
  30.     [super setStringValue:s];
  31.     [self setLeaf:YES];
  32.     [self setAction:@selector(click:)];
  33.     [self setTarget:self];
  34.     return self;
  35. }
  36.  
  37. static id f = (id)0;
  38.  
  39. - setContents:(int)N {
  40.     extern char *nthItem();
  41.     extern int nthItemIndex();
  42.     
  43.     if (!f) f = [Font newFont:"Courier" size:12.];
  44.     [self setFont:f];
  45.     [super setStringValueNoCopy:s=nthItem(N)];
  46.     n = nthItemIndex(N);
  47.     return self;
  48. }
  49.  
  50. - setStringValue: (char *)s {
  51.     return [self setStringValueNoCopy:s];
  52. }
  53.  
  54. - (char *)stringValue {
  55.     return s;
  56. }
  57.  
  58. @end